<?php
//naincludujeme potrebne classy, zapneme nette
require 'nette/Nette/loader.php';
Debug::enable();
require 'db.php';
require 'localization/lang.php';
require 'core/core.sanitizer.php';
require 'core/core.security.php';
require 'core/core.usermanagement.php';
session_start();
$loc=new loc;
//ak prislo logging info, skontrolujem a ked je to ok tak sa lognem


if (isset($_POST['log_in'])) {
$login = new core_security;
$login->username=$_POST['username'];
$login->passwd=$_POST['passwd'];
$login_validation_message=$login->checkuser_validate();
$login->setlogin();
}
if (isset($_POST['logout'])) {
if ($_POST['logout'] == "log out") {
$login = new core_security;
$login->unsetlogin();
}
}

if (isset($_SESSION['logged'])) {

if (isset($_POST['switch'])) {
	if ($_POST['switch']=="attend") {$_SESSION['view']="attend";}
	if ($_POST['switch']=="main") {$_SESSION['view']="main";}
	}

if ($_SESSION['logged'] == "OK") {
	if ($_SESSION['view']=="main") {


	//tu sa naincluduje user stranka

	require 'main.inc.php';
	}
	if ($_SESSION['view']=="attend") {
	require 'attendance.inc.php';
	}
}
}else{
require 'login_form.inc.php';
}
?>
